package src.main.java;

import java.util.*;

public class MapMain {
    public static void main(String[] args) {
//        Scanner scan=new Scanner(System.in);
//        Map<Integer,String>hm=new HashMap<Integer,String>();
//        hm.put(1,"Amy");
//        hm.put(2,"Joe");
//        hm.put(3,"Tom");
//        hm.put(4,"Susan");
//        Set hp=hm.keySet();
//        for (Object obj:hp){
//            System.out.println(obj+":"+hm.get(obj));
//        }
//        hm.put(5,scan.next());
//        hm.remove(4);
//        hm.replace(3,"Tommy");
//        Set mp=hm.keySet();
//        System.out.println("");
//        for (Object ob:mp){
//            System.out.println(ob+":"+hm.get(ob));
//        }


        String[]str={"a","b","a","b","c","a","b","c","b"};
        int a=0;
        int b=0;
        int c=0;
        List list=Arrays.asList(str);//数组转集合
        for (int i=0;i<list.size();i++){
            if (list.get(i).equals("a")){
                a++;
            }else if (list.get(i).equals("b")){
                b++;
            }else{
                c++;
            }
        }
        Set set=new HashSet();
        set.addAll(list);//list转set

        List st=new ArrayList();
        st.addAll(set);//set转list

        Map map=new HashMap();
        map.put(st.get(0),a);
        map.put(st.get(1),b);
        map.put(st.get(2),c);

        Set se=map.keySet();
        for (Object obj:se){
            System.out.println(obj+":"+map.get(obj));
        }
    }
}
